package nz.ac.massey.jfontview.example;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.UIManager;

import nz.ac.massey.jfontview.FontList;
import nz.ac.massey.jfontview.FontSelector;

/**
 * An example application using the font viewer.
 * 
 * @author Nathan C Jones
 * @version 0.1
 */
public class Example {

	public static void main(String[] args) {
		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		JFrame frame = new JFrame("Font Viewer Example");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		Container contentPane = frame.getContentPane();
		contentPane.setLayout(new BorderLayout());
		
		FontList fonts = new FontList();
		//TODO load serialised list instead of static list
		fonts.add(new Font("Arial",Font.BOLD,12));
		fonts.add(new Font("Courier New",Font.ITALIC,14));
		fonts.add(new Font("Verdana",Font.PLAIN,10));
		fonts.add(new Font("Times New Roman",Font.BOLD|Font.ITALIC,14));
		
		FontSelector fontViewer = new FontSelector(fonts);
		contentPane.add(fontViewer,BorderLayout.CENTER);
		
		frame.pack();
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		frame.setLocation((screenSize.width-frame.getWidth())/2,(screenSize.height-frame.getHeight())/2);
		frame.setVisible(true);
	}

}
